package com.example.myapplication

import android.util.Log
import com.example.myapplication.databinding.ActivityUpdateFwCircleBinding

class UpdateFwCircleActivity : BaseActivity<ActivityUpdateFwCircleBinding>(),
    UpdateFwCircleView.IUpdateFwCircleView {
    override fun getLayoutId(): Int {
        return R.layout.activity_update_fw_circle
    }


    override fun init() {
        dataBinding.start.setOnClickListener {
            // Update firmware
            dataBinding.updateCircleView.startAnimation(this,   dataBinding.et.text.toString().toInt())
        }

        dataBinding.pause.setOnClickListener {
            // Pause firmware update
            if(dataBinding.pause.text == "Pause"){
                dataBinding.updateCircleView.pause()
                dataBinding.pause.text = "Resume"
            }else {
                dataBinding.updateCircleView.resume()
                dataBinding.pause.text = "Pause"
            }
        }

        dataBinding.stop.setOnClickListener {
            // Cancel firmware update
            dataBinding.updateCircleView.stopAnimation()
        }
    }


    override fun animatorUpdate(process: Int, second: Int) {
        this.dataBinding.start.text = "start : $process  second : $second"
    }

    override fun animatorTimeEnd() {
        Log.d("UpdateFwCircleActivity", "animatorTimeEnd")
        this.dataBinding.start.text = "start"
    }
}